<%@page import="com.wowangz.cms.common.utils.DictTypeConstant"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/pageHead.jsp"%>
<script src="${systemctx}/resources/ckeditor/ckeditor.js"></script>
<script src="${systemctx}/resources/ckeditor/config.js?v=1"></script>
<style>
	
</style>
<script type="text/javascript">
	function getValue() {
		$editor = CKEDITOR.instances.editor01.getData();
		alert($editor);
	}
	var setting = {
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			onClick: onClick
		}
	};
	
	var zNodes = ${treeJson};
	
	function onClick(event, treeId, treeNode) {
		$("#parentcolumnname").val(treeNode.name);
		$("#parentcolumn").val(treeNode.id);
		$(".treeColumn").css('display','none');
	}		
	$(document).ready(function(){
		$.fn.zTree.init($("#treeDemo"), setting, zNodes);
	});
	$(document).ready(function() {
		$("#display").selectutil({
			optModel : <%=SysConstant.Display.getMode1JSONString(true, false)%>,
			optDefault :''
		});
		
		$("#parentcolumnname").click(function(){
			$("#columnTree").css('display','block').css('left',$(this).offset().left);
		});
		$("#parentcolumnname").keyup(function(){
			var parentcolumnname = $("#parentcolumnname").val();
			if(parentcolumnname==''){
				$('#parentcolumn').val('');
			}
		});
		$(".treeColumn").mouseleave(function(){
			$(".treeColumn").css('display','none');
		});
		
		$("#butReturn").click(function(){
			window.location.href="${systemctx}/topic/news/queryNewsList.web";
		});
	});
	function save(){
		var exp = $('#form1').validationEngine('validate');
		var parentcolumnname = $("#parentcolumnname").val();
		if(parentcolumnname==''){
			$('#parentcolumn').val('');
		}
		var content = CKEDITOR.instances.editor01.getData();
		
		$("#contents").val(content);
		if(exp==true){
			if(content == ''){
				alert('<%=MessageResourcesUtils.getMessage(request, "topic.news.contents.alert")%>');
				return ;
			}
			// 显示进度条
			showSending();
			$.ajax({
				type: 'POST',
			    url: '${systemctx}/topic/news/saveNews.json',
			    data: $("#form1").serialize(),
			    dataType: 'json',
			    success: function(data) {
			    	//关闭执行...
					closeSending();
			    	if(data.messagetype == 1){
			    		alert(data.message)
			    		window.location.href = "${systemctx}/topic/news/queryNewsList.web";
			    	}else {
			    		alert(data.message)
			    		return;
			    	}
			    }
			});
		}
	}
</script>
<form name="form1" id="form1" action="" method="post">
	<input type="hidden" id="contentFilter" name="contentFilter" value="<%=SysConstant.YesOrNo.NO %>">
	<div class="pageMain">
		<div class="pageTitle">
			<%=MessageResourcesUtils.getMessage(request, "systemmanage.contentmanagement.title")%>
			<span></span>
			<%=MessageResourcesUtils.getMessage(request, "topic.news.title") %>
			<span></span>
			<%=MessageResourcesUtils.getMessage(request, "topic.news.module.add.title") %>
		</div>
		<div class="pageBody">
			<table class="formTableCommStyle" id="editTable">
				<tr>
					<td class="TableTd1">
						<i>*</i>
						<%=MessageResourcesUtils.getMessage(request, "topic.news.col.newscode") %>
					</td>
					<td class="TableTd2" colspan="3">
						<input type="hidden" name="newscode" id="newscode" value="${newscode}">
						<input type="text" class="" readonly="readonly" value="${newscode}">
					</td>
				</tr>
				<tr>
					<td class="TableTd1">
						<i>*</i>
						<%=MessageResourcesUtils.getMessage(request, "topic.news.col.columnname") %>
					</td>
					<td class="TableTd2" colspan="3">
						<input type="hidden" name="parentcolumn" id="parentcolumn">
						<input type="text" class="validate[required]" readonly="readonly"  name="parentcolumnname" id="parentcolumnname">
						<div id="columnTree" class="treeColumn">
							<div class="zTreeDemoBackground left">
								<ul id="treeDemo" class="ztree"></ul>
							</div>
						</div>
					</td>
				</tr>
				<tr>
					<td class="TableTd1">
						<i>*</i>
						<%=MessageResourcesUtils.getMessage(request, "topic.news.col.title")%>
					</td>
					<td class="TableTd2" colspan="3">
						<input  type="text" name="title" id="title" class="news_title validate[required,maxSize[240]]">
					</td>
				</tr>
				<tr>
					<td class="TableTd1" colspan="4">
						<i>*</i>
						<%=MessageResourcesUtils.getMessage(request, "topic.news.col.contents") %>
					</td>
				</tr>
				<tr>
					<td class="TableTd1" colspan="4">
						<textarea cols="50" r name="contents" style="display: none;" id="contents"></textarea>
						<textarea id="editor01"></textarea>
						<script type="text/javascript">
							CKEDITOR.replace('editor01');
							$(document).ready(function(){
								$("#cke_editor01_arialbl").css('display','none');
							});
						</script>
					</td>
				</tr>
			</table>
			<div class="button-group">
				<input type="button" class="btn btn-default" id="butSave" onclick="save()" name="butSave"  value='<%=MessageResourcesUtils.getMessage(request, "common.button.save") %>' />
				<input type="button" class="btn btn-default" id="butReturn" name="butReturn" value='<%=MessageResourcesUtils.getMessage(request, "common.button.back") %>' />
			</div>
		</div>
	</div>
</form>

<%-- 引入页面尾 --%>
<%@ include file="/pageFloor.jsp"%>